package my.wudm.yummy.common.factory;

import my.wudm.yummy.common.BaseParse;

import java.util.HashMap;
import java.util.Map;

public class ParseFactory {

    private final static String  PARST_BASE_PATH ="my.wudm.yummy.worker.parse.";

    private final static Map<String, String> PARSE_MAP = new HashMap<>();

    static {
        PARSE_MAP.put("Biqu", "BiquParse");
    }

    public static BaseParse getInstance(String parseType) {
        String className = PARSE_MAP.get(parseType);

        try {
            return (BaseParse) Class.forName(PARST_BASE_PATH + className).newInstance();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
        return null;
    }
}
